{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-11-04T05:36:36.257539Z",
     "start_time": "2025-11-04T05:36:36.252887Z"
    }
   },
   "source": "import pandas as pd",
   "outputs": [],
   "execution_count": 8
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-04T05:36:36.278007Z",
     "start_time": "2025-11-04T05:36:36.273768Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 定义数据\n",
    "X = [[5], [8], [10], [12], [15], [3], [7], [9], [14], [6]]\n",
    "y = [55, 65, 70, 75, 85, 50, 60, 72, 80, 58]"
   ],
   "id": "781c6c47641f23d",
   "outputs": [],
   "execution_count": 9
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-04T05:36:36.295941Z",
     "start_time": "2025-11-04T05:36:36.290459Z"
    }
   },
   "cell_type": "code",
   "source": [
    "X = pd.DataFrame(X)\n",
    "y = pd.Series(y)\n",
    "print(X.shape)\n",
    "print(y.shape)"
   ],
   "id": "1e2a640eb4efebfa",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(10, 1)\n",
      "(10,)\n"
     ]
    }
   ],
   "execution_count": 10
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-04T05:36:42.873384Z",
     "start_time": "2025-11-04T05:36:36.345651Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#计算斯皮尔曼相关系数\n",
    "print(X.corrwith(y, method='spearman'))"
   ],
   "id": "b097765e68828b7b",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0    0.987879\n",
      "dtype: float64\n"
     ]
    }
   ],
   "execution_count": 11
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
